<template>
    <div class="container" @click="handleGallary">
        <div class="wrapper">
            <swiper :options="swiperOption"> 
                <swiper-slide v-for="(item,i) in gallaryImg" :key="i">
                    <img class="gallary-img" :src="item" alt="">
                </swiper-slide>
                <div class="swiper-pagination"  slot="pagination"></div>
            </swiper>
        </div>
    </div>
</template>

<script>
    export default {
        props:{
            gallaryImg:{
                type:Array,
                default(){
                    return []
                }
            }
        },
        data() {
            return {
                swiperOption:{
                    pagination:'.swiper-pagination',
                    paginationType:'fraction',
                    // 解决轮播宽度的问题。当监听该元素或者父级元素DOM发生变化时，会刷新一次
                    observeParents:true,
                    observer:true
                }
            }
        },
        methods: {
            // 向父级元素传递关闭展示图事件
            handleGallary(){
                this.$emit('closeGallary')
            }
        },
    }
</script>

<style lang="stylus" scoped>
.container >>> .swiper-container
    overflow inherit
.container
    display flex
    flex-direction column
    justify-content center
    position fixed
    left 0
    right 0
    top 0
    bottom 0
    z-index 2
    background #000
    .wrapper
        width 100%
        height 0
        padding-bottom 100%
        background #fff
        .gallary-img
            width 100%
        .swiper-pagination
            color #fff
            bottom -1rem
</style>